<template>
  <div class="province-sale-box">
    <div class="select-box">
      <div class="province-box">
        <div class="select1">
          <AreaSelect></AreaSelect>
        </div>
        <DatePicker></DatePicker>
      </div>
    </div>
    <SumSale></SumSale>
    <TabProvince></TabProvince>
  </div>
</template>

<script>
import {getCopartnerdatas} from "../../api/datas"
import {Bus} from "../../Bus"
import AreaSelect from "../../components/sales/areaSelect";
import DatePicker from "../../components/sales/DatePicker";
import SumSale from "../../components/sales/SumSale";
import TabProvince from "../../components/sales/TabProvince";
export default {
  components: {
    AreaSelect,
    DatePicker,
    SumSale,
    TabProvince,
  },
  data() {
    return {
      province:"",
      stime:"",
      etime:"",
      lists: [
        {
          name: "省",
          prop: "province",
        },
        {
          name: "销量",
          prop: "sales",
        },
      ],
       provinceSales: [
        {
          province:"",
          sales:""
        },
        {
          province:"",
          sales:""
        }
      ],
    };
  },
  mounted(){
    Bus.$on("province",(value)=>{
      this.province = value;
      console.log(this.province);
    });
    Bus.$on("stime",(value)=>{
      this.stime = value;
    });
    Bus.$on("etime",(value)=>{
      this.etime = value;
    });
    Bus.$emit("province-lists",this.lists);

    //获取全部大客户合伙人数据
    getCopartnerdatas({}).then(res=>{
      let idx = 0;
      for( let item of res.counts){
        console.log(item);
        this.provinceSales[idx].province = item.province;
        this.provinceSales[idx].sales = item.sale;
        idx++;
      }
      Bus.$emit("provinde-datas",this.provinceSales)
    })
  },
};
</script>

<style lang="less" scoped>
.province-sale-box {
  padding-top: 30px;
}
.select-box {
  margin-left: 30px;
  width: inherit;
}
.province-box {
  display: flex;
}
.select1{
  margin-right: 50px;
  width: 400px;
}
</style>